package com.pomr.model.synthesize;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.Formula;
import org.hibernate.annotations.GenericGenerator;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pomr.model.menu.EquipmentKind;
import com.pomr.model.sys.User;

/**
 * 设备基本信息表
 * @author Administrator
 * 名称、规格 唯一
 */
@Entity
@Table(name="equipment",uniqueConstraints = {@UniqueConstraint(columnNames={"kind_id","specification"})})
public class Equipment implements Serializable{
	public EquipmentKind getKind() {
		return kind;
	}
	public void setKind(EquipmentKind kind) {
		this.kind = kind;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getIdentifier() {
		return identifier;
	}
	public void setIdentifier(String identifier) {
		this.identifier = identifier;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSpecification() {
		return specification;
	}
	public void setSpecification(String specification) {
		this.specification = specification;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "native")
    @GenericGenerator(name = "native", strategy = "native")//AUTO 在mysql中需要指定使用本地策略生成主键值
	private Integer id;//	主键
	@Column(name="identifier",length=20)
	private String identifier;//	编号
	
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="kind_id")
	private EquipmentKind kind;//设备种类
	
	@Formula("(select k.name from menu_equipment k where k.id=kind_id)")
	private String name;//	设备名称
	
	@Column(name="specification",length=20)
	private String specification;//	规格（型号）
	@Column(name="remark",length=100)
	private String remark;//	备注（功能等）
	@Column(name="status",length=1,columnDefinition="varchar(1) default '0'")
	private String status;//状态 1：停用
	@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
	@Column(name="create_time")
	private Date createTime;//创建时间
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="createuser_id")
	private User user;//创建人
	
	@Formula("(select u.name from user u where u.id=createuser_id)")
	private String userName;


}
